<template>
  <fieldset>
    <legend>钩子函数</legend>
    <!-- <h1>{{ num }}</h1> -->
    <h2>{{ num2 }}</h2>
    <h3>{{ aa }}</h3>
  </fieldset>
</template>
<script>
import { toRefs, getCurrentInstance } from "vue";
export default {
  props: ["num"],
  setup(props, context) {
    // console.log("props", props);
    // console.log("context", context);
    let { num } = toRefs(props);
    //获取组件实例getCurrentInstance
    let proxy = getCurrentInstance();
    console.log(proxy);
    //不能通过this获取组件实例
    console.log(this); //undefined
    console.log(context); //{"attrs": {},"slots": {},expose: (exposed) => {…},slots: (...)}
    //输出插槽节点
    console.log(context.slots);
    return {
      num2: num,
      aa: 999,
    };
  },
};
</script>
<style scoped></style>
